package opera1;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOPeration {
    @Override
    public void work(BookList bookList) {
        Scanner input = new Scanner(System.in);
        int currentUsedsize = bookList.getUsedSize();
        System.out.println("输入你要归还的书名:");
        String bookName = input.nextLine();
        for (int i = 0; i < currentUsedsize; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(bookName) && book.isBorrowed()) {
                book.setBorrowed(false);
                System.out.println("归还成功!");
                return;
            }
        }
    }
}
